-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
feat: $state.eager(value)
(runtime-first approach)
#16926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: $state.eager(value)
(runtime-first approach)
#16926
Conversation
🦋 Changeset detectedLatest commit: 61adc3d The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
If cursor was at end and new input is longer, move cursor to new end No test because not possible to reproduce using our test setup. Follow-up to sveltejs#14649, helps with sveltejs#16577
If we can get this to work, that'd would be way better. Right now I'm seeing some glitchy behaviour — I suspect it's less caused by this PR than revealed by it, but either way we need to investigate. With the other PR it's possible to get into a broken state if you spam the button enough... Screen.Recording.2025-10-13.at.2.48.02.PM.mov...but with this PR it seems to happen much more easily: Screen.Recording.2025-10-13.at.2.49.45.PM.mov |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Updated code block syntax from Svelte to JavaScript for clarity.
Basically as soon as you have an |
* fix: unset context on stale promises When a stale promise is rejected in `async_derived`, and the promise eventually resolves, `d.resolve` will be noop and `d.promise.then(handler, ...)` will never run. That in turns means any restored context (via `(await save(..))()`) will never be unset. We have to handle this case and unset the context to prevent errors such as false-positive state mutation errors * fix: unset context on stale promises (slightly different approach) (sveltejs#16936) * slightly different approach to sveltejs#16935 * move unset_context call * get rid of logs --------- Co-authored-by: Rich Harris <rich.harris@vercel.com>
I'm somewhat confident this is the same bug that caused me to add the |
I wonder if #16944 fixes this |
…6943) * fix(svg radialGradient): fr attribute missing in types * chore: add changeset
* Version Packages * Update packages/svelte/CHANGELOG.md --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Rich Harris <rich.harris@vercel.com>
I merged that branch into this one, and it's definitely a lot more stable than it is at present — there's still some glitchiness (things can get out of sync while work is ongoing) but it always ends up in a correct state |
* chore: simplify `batch.apply()` * belt and braces * note to self
Since sveltejs#16866, when an async effect runs multiple times, we rebase older batches and rerun those effects. This can have unintended consequences: In a case where an async effect only depends on a single source, and that single source was updated in a later batch, we know that we don't need to / should not rerun the older batch. This PR makes it so: We collect all the sources of older batches that are not part of the current batch that just committed, and then only mark those async effects as dirty which depend on one of those other sources. Fixes the bug I noticed while working on sveltejs#16935
quick follow-up to sveltejs#16944 Resetting a map entry does not change its position in the map when iterating. We need to make sure that reset makes that batch jump "to the front" for the "reject all stale batches" logic below. Edge case for which I can't come up with a test case but it _is_ a possibility.
* feat: add `createContext` utility for type-safe context * regenerate
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
$effect.pending(value)
(runtime-first approach)$state.eager(value)
d8e61f6
into
sveltejs:effect-pending-value
$state.eager(value)
$state.eager(value)
(runtime-first approach)
This lifts the restriction of having to put this lexically inside an effect, now it can appear anywhere as long as it's called in the context of an effect or derived. We're leveraging the existing pending logic but instead of returning a number we're executing the function that was passed and return its result. We also have a map with all the current source values which is used for the duration of the execution of said function.